<cftry>
<cfoutput>
<cfset parmlist=URLEncodedFormat('un~demo123|pswd~demo123|method~processtranx|tranxtype~sale|terms~Y|swipe~%B4012881888818888^JOHN JONES             ^1511101023370001000000546000000?;4012881888818888=15111010233754600001?|amount~#form.amount#|baddress~1234 Main|bzip~99201|invoice~123456abcd|')>
<cfhttp url="https://PayTrace.com/API/default.pay?parmList=#parmlist#"></cfhttp>

  
<cfset checkcust = "#cfhttp.filecontent#">
<cfif NOT ListLen(checkcust,"~") GTE 2>
	Error Occurred. checkcust = #checkcust#
	<cfabort>
<cfelse>
</cfif>
<cfset checkone = listGetAt(checkcust, 1, "~")>
<cfset checktwo = listGetAt(checkcust, 2, "~")>

<cfif NOT ListLen(checktwo,"~") GTE 2>
	Error Occurred. checktwo = #checktwo#
	<cfabort>
<cfelse>
</cfif>

<cfset checkthree = listGetAt(checktwo, 1,".")>
<cfset checkfour = listGetAt(checktwo, 2,".")>


  
  
  
  
  
<cfset today = dateformat(now(), "mm/dd/yyyy")>
<cfset mytime = timeformat(now(), "hh:mm:ss")>

<cfset checkcard = "#form.cc#">

<cfif NOT ListLen(checkcard,"~") GTE 2>
	Error Occurred. checkcard = #checkcard#
	<cfabort>
<cfelse>
</cfif>

<cfset cc_lastName =  listgetAt(checkcard,2,"/^;")>
<cfset cc_firstName =  listgetAt(checkcard,3,"/^;")>


<cfset par_cc_num =  listgetAt(checkcard,1,"%^;")>

<cfset cc =  right(par_cc_num,16)>

<cfset par_date =  listgetAt(checkcard,3,"^?;")>

<cfset cc_date =  left(par_date,4)>

<cfset cc_year =  left(par_date,2)>
<cfset cc_month =  right(cc_date,2)>


<cfset lastfour =  right(par_cc_num,4)>

<CFQUERY NAME="getitemssum" DATASOURCE="#dsn#">
select sum(Price) as total
from tbltransactions
where ReceiptNum = #session.ReceiptNum#
</CFQUERY>

Got this far
<cfset mychange = #form.amount# - #getitemssum.total#>

<cfset myblance = #mychange#>


<cfquery datasource="#dsn#">
update tblorders
set Amount = #amount#,
LastFour = #lastfour#,
FirstName = '#cc_firstName#',
LastName = '#cc_lastName#',
Paytype = 'Credit Card',
Credit = #amount#,
TransType = 'POS'
where ReceiptNum = #session.ReceiptNum# 
</cfquery>



<CFQUERY DATASOURCE="#dsn#">
INSERT INTO tblpayments (Amount, ReceiptNum, TransDate, ReportTime, ReportDate, PaymentType, PIN, Change, username, amountpaid, Balance, TransType, Credit)
VALUES (
#Amount#,
#session.ReceiptNum#,
<cfqueryparam cfsqltype="cf_sql_timestamp" value="#today#">,
'#mytime#',
'#today#',
'Credit Card',
#session.pin#,
0,
'#session.username#',
#Amount#,
<cfif #myblance# gte 1>#myblance#<cfelse>0</cfif>,
'Purchase',
#Amount#
 
)
</CFQUERY>

<CFQUERY NAME="getcodes" DATASOURCE="#Datasource#">
select *
from tblresponsecodes
where Code = #checkthree#
</CFQUERY>

<cflocation url="credit.cfm?response=#checkthree# #checkfour#">

  

</cfoutput>
<cfcatch type="Any">
	An error occured. Please try again.
</cfcatch>
</cftry>